package com.ygp.dtp.core.notify;

import com.google.common.collect.Lists;
import com.ygp.dtp.common.config.properties.DtpProperties;
import com.ygp.dtp.common.config.threadpool.ThreadPoolProperties;
import com.ygp.dtp.common.dto.DynamicThreadPoolMainProperty;
import com.ygp.dtp.common.dto.NotifyItem;
import com.ygp.dtp.common.dto.NotifyPlatform;
import com.ygp.dtp.common.enums.NotifyTypeEnum;
import com.ygp.dtp.core.thread.DynamicThreadPoolExecutor;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @description: 通知帮助类
 * @motto: 代码源于生活，高于生活艺术
 * @author: zhouhengzhe
 * @date: 2022/8/10 14:36
 * @since 1.0
 **/
public class NotifyHelper {


    public static final List<String> COMMON_ALARM_KEYS = Lists.newArrayList("alarmType", "threshold");

    public static final List<String> LIVENESS_ALARM_KEYS = Lists.newArrayList(
            "corePoolSize", "maximumPoolSize", "poolSize", "activeCount");

    public static final List<String> CAPACITY_ALARM_KEYS = Lists.newArrayList(
            "queueType", "queueCapacity", "queueSize", "queueRemaining");

    public static final List<String> REJECT_ALARM_KEYS = Lists.newArrayList("rejectType", "rejectCount");

    public static final Set<String> ALL_ALARM_KEYS =
            Stream.of(COMMON_ALARM_KEYS, CAPACITY_ALARM_KEYS, REJECT_ALARM_KEYS, LIVENESS_ALARM_KEYS)
                    .flatMap(Collection::stream).collect(Collectors.toSet());



    public static NotifyItem getNotifyItem(DynamicThreadPoolExecutor threadPoolExecutor, NotifyTypeEnum change) {
        return null;
    }

    public static void setExecutorNotifyItems(DynamicThreadPoolExecutor threadPoolExecutor, DtpProperties dtpProperties, ThreadPoolProperties threadPoolProperties) {

    }

    public static NotifyHelper getInstance() {
        return new NotifyHelper();
    }

    public static void fillNotifyItems(List<NotifyPlatform> platforms, List<NotifyItem> notifyItems) {

    }

    public void sendNotify(DynamicThreadPoolMainProperty oldProperties, DynamicThreadPoolMainProperty newProperties) {

    }
}
